package org.NooLab.glue.net.http.rest;

import java.util.Observable;

import org.NooLab.glue.components.DataSenderIntf;
import org.NooLab.utilities.logging.PrintLog;



/**
 * the purpose of this class is to provide the standard DataSenderIntf to the messageBoard
 * for returning results into a living ClientResource, which is waiting for it in order to
 * use it as an element for the http-response WITHIN the same session
 * 
 * 
 * @author kwa
 *
 */
public class HttpRestletInternalSender extends Observable implements DataSenderIntf{

	HttpRestletServer serverReceiver;
	
	PrintLog out = new PrintLog(2, true);
	
	
	
	public HttpRestletInternalSender( HttpRestletServer serverreceiver ){
		serverReceiver = serverreceiver ;
		
	}

	@Override
	public void send(Object obj) {
		send(obj,"");
	}
	
	@Override
	public void send(Object obj, String suid) {
		 
		String msg="" ;
		
		msg = (String)obj;
		// its simply a notification !
		
		// engine returns to here !!! 
		// outx out.print(4, "HttpRestletInternalSender, relaying returned results back to http instance... \n"); // + msg) ;
		
		// trigger notification
		// serverReceiver is of type "HttpRestletServer{}"
		// 
		serverReceiver.returningResultsForResponse(msg);
	}

	@Override
	public void release() {
 
		
	}

	@Override
	public void setTimeOut(int value) {
	 
		
	}

	

	@Override
	public int getLastState(String suid) {
		// here it is always 0 ? 
		// if connection broke within session ? 
		// we can not get it, since we use Observers for routing the message internally... 
		return 0;
	}
	
	
}
